
package data;

import java.sql.*;
/**
 *
 * @author Alejandro
 */
public class BitacoraDataMapper {
    private Connection conexion;
    
    public BitacoraDataMapper(){
        Conector conector = new Conector();
        conexion = conector.darConexion();
        Statement stmt;
        try {
            stmt = conexion.createStatement();
            stmt.execute("use be");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
    
    public boolean verificarCedulaProf(String cedula){
        boolean existe = false;
        Statement stmt;
        try {
            stmt = conexion.createStatement();
            ResultSet rs = stmt.executeQuery("Select * from Profesor where cedula = \'"+cedula+"\'");
            if(rs.next()) existe = true;
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        
        return existe;
    }
    
    public ResultSet obtenerBitacorasProfesor(String cedula){
        Statement stmt;
        ResultSet rs = null;
        try {
            stmt = conexion.createStatement();
            rs = stmt.executeQuery("Select b.codigoBitacora, c.nombre from Bitacora b, Profesor p, Curso c where p.cedula = \'"+cedula+"\' and  c.CedulaProfesor = \'"+cedula+"\' and b.cedulaProfesor = \'"+cedula+"\'");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        
        return rs;
    }
    
    public boolean verificarIDBitacora(String ID){
        boolean existe = false;
        Statement stmt;
        try {
            stmt = conexion.createStatement();
            ResultSet rs = stmt.executeQuery("Select * from Bitacora where codigoBitacora = \'"+ID+"\'");
            if(rs.next()) existe = true;
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        
        return existe;
    }
}
